<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/11/6 0006
 * Time: 下午 3:17
 */

namespace app\controller;


use app\model\Users;
use think\Container;
use think\facade\View;

class Show
{

    public $name="tom";
    public $age = 100;
    const PI = 222;
    function fn(){
        return "method";
    }
    function index(){


        Container::getInstance()['shut']->hello();


        //require "test/1.php";
        //View::assign("name","jack");
//        View::assign([
//            "name"=>"wocao"
//        ]);
//        return View::fetch();//Driver [Think] not supported.  该版本不支持模板引擎

//        return view("index",[

//            "name"=>"tom",
//            "city"=>["beijing","shanghai"]
//        ]);

//        return View::filter(function($content){
//            return strtoupper($content);
//        })->fetch("index",["name"=>"ok","city"=>["beijing","shanghai"]]);

        //模板配置修改
        //View::config(["view_dir_name"=>"view2"]);
       // return view("index",["name"=>"ok","city"=>["beijing","shanghai"]]);
        //return view("show/index",["name"=>"ok","city"=>["beijing","shanghai"]]);
        //return view("admin@show/index",["name"=>"ok","city"=>["beijing","shanghai"]]);
        //return view("./index",["name"=>"ok","city"=>["beijing","shanghai"]]);
        //使用原生的php
        return View::engine("php")->fetch("test/1.php");
    }


    function output(){

        $arr = ["name"=>"jack","age"=>200];
        return view("output",[
            'arr'=>$arr,
            'obj'=>$this,
            'password'=>'12345',
            'time'=>time(),
            'number'=>100
        ]);
    }

    function loop(){

        $list = Users::where("sex",0)->select();
        return view("loop",[
            "list"=>$list
        ]);
    }

    function eq(){

        return view("eq",[
            "name"=>"cs",
            "name2"=>"cs"
        ]);
    }

    function condition(){

        return view("condition",[
            "number"=>10,
            "id"=>10
        ]);
    }

    function block(){

        return View::fetch("block",[
            "title"=>"我是牛逼的标题"
        ]);
    }

    function form(){

        return View::fetch("form",[
            "title"=>"我是牛逼的标题"
        ]);
    }
}